package com.fanling.venus.project.service;

import com.fanling.venus.project.domain.FinancialBalance;
import com.fanling.venus.project.mapper.FinancialBalanceMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FinancialBalanceService {

    @Autowired
    protected FinancialBalanceMapper financialBalanceMapper;

    /**
     * 财务列表
     *
     * @param financialBalance
     * @return
     */
    public List<FinancialBalance> selectFinancialBalanceList(FinancialBalance financialBalance) {
        return financialBalanceMapper.selectFinancialBalanceList(financialBalance);
    }

    /**
     * 财务数据
     *
     * @param balanceId
     * @return
     */
    public FinancialBalance selectFinancialBalanceById(Long balanceId) {
        return financialBalanceMapper.selectFinancialBalanceById(balanceId);
    }

    /**
     * 财务新增
     *
     * @param financialBalance
     * @return
     */
    public int insertFinancialBalance(FinancialBalance financialBalance) {
        return financialBalanceMapper.insertFinancialBalance(financialBalance);
    }

    /**
     * 财务删除
     *
     * @param balanceId
     * @return
     */
    public int deleteFinancialBalanceById(Long balanceId) {
        return financialBalanceMapper.deleteFinancialBalanceById(balanceId);
    }

    /**
     * 财务修改
     *
     * @param financialBalance
     * @return
     */
    public int updateFinancialBalance(FinancialBalance financialBalance) {
        return financialBalanceMapper.updateFinancialBalance(financialBalance);
    }

    /**
     * 根据类别获取总金额
     *
     * @param source
     * @return
     */
    public String selectFinancialBalanceSumByType(String source) {
        FinancialBalance financialBalance = new FinancialBalance();
        financialBalance.setSource(source);
        return financialBalanceMapper.selectFinancialBalanceSumByType(financialBalance);
    }

    /**
     * 按日统计收支
     *
     * @return
     */
    public List<FinancialBalance> selectFinancialBalanceSumByDays() {
        return financialBalanceMapper.selectFinancialBalanceSumByDays();
    }

    /**
     * 按月统计收支
     *
     * @return
     */
    public List<FinancialBalance> selectFinancialBalanceSumByMonth() {
        return financialBalanceMapper.selectFinancialBalanceSumByMonth();
    }
}
